/*
 * IsNumber.java
 *
 * Created on 28 de Dezembro de 2006, 14:57
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package reportcenter.support;


/**
 *
 * @author renan_luz
 */
public class IsNumber {
    
    /** Creates a new instance of IsNumber */
    public IsNumber() {
    }
    
    public static boolean isNumeric(String s) {
        final char[] numbers = s.toCharArray();
        for (int x = 0; x < numbers.length; x++) {
            final char c = numbers[x];
            if ((c >= '0') && (c <= '9')) continue;
            return false; // invalid
        }
        if (numbers.length > 0) {
            return true;// valid
        } else {
            return false;
        }
    }
    
    public static boolean isNumeric(char c){
            if ((c >= '0') && (c <= '9')) return true;
            return false; // invalido
    }
    
    public static boolean isDecimal(String s){
        s = s.replace(",", ".");
        boolean returnValue = true; //valido
        try{
            Double.valueOf(s);
        }catch(NumberFormatException nex){
            returnValue = false;
        }
        return returnValue;
    }
}
